<?php
	require_once( '../system/mdao/Class_M_OTHER.php' );
	require_once( '../system/smarty.inc' );
	require_once( '../system/aoki_m.php' );
	$v = NULL;
	$para = "";
	if( isset($_GET['t']) && $_GET['t'] != '' ){
		$para = $_GET['t'];
		if( isset($_GET['v']) && $_GET['v'] != '' ){
			$value = lTrim(rTrim( urldecode($_GET['v']) ));
		}
	} else {
		echo "検索エラー";
		exit;
	}
	$forms = $_GET;
	$p =  $_GET['p'];
	$w =  $_GET['w'];
		
	$page = array();
	if( isset( $_GET['page'] ) && is_numeric( $_GET['page'] ) ){		
		$page['current'] = $_GET['page'];	
	}else{
		$page['current'] = 1;
	}
	$beginopen = TRUE;
	if( isset( $_GET['sear'] ) && ( $_GET['sear'] == '1') ){
		$beginopen = FALSE;
	}
	
$login_auth = $login['staff_auth'];

if ($login_auth == 'G-2' ) {
	$area_cd   = $login['autoid'];
	$forms["sort"] = '2';
	$areauser = array($aja_cd => $login['staff_id']." ".$login['staff_name'] );
}else if ($login_auth == 'G-3' ) {
	$zone_cd   = $login['autoid'];
	
	$forms["sort"] = '3';
	$cellsort = array();
	
	$zone_cd = array($aja_cd => $login['staff_id']." ".$login['staff_name'] );
}else {
	
	//if  ( empty($forms["sort"])) {
	//	$forms["sort"] = 2;
		
	//}
	$zoneuser  = array();
	$zoneuser  = Class_M_OTHER::get_ajaeks_array(NULL, 3);
	$areauser = array();
	$areauser =  Class_M_OTHER::get_ajaeks_array(NULL, 2);
	$zone_cd = array();
	//$zone_cd[""] =  PLEASE_SELECT_ARR ;
	
	//foreach ($zoneuser as $k =>$v ){
	//	$zone_cd[$v["userid"]]  = $v["login_id"]."  ".$v["user_name"] ;
	//}
}

$page = NULL;
if  ($forms["sort"] == '2') {
	$area_cd  = $forms['ar'];
	$data = Class_M_OTHER::get_shopdnpwp($w, $p,$value,$area_cd,NULL, $page);

} elseif  ($forms["sort"] == '3') {
	$zone_cd  = $forms['zo'];;
	$data = Class_M_OTHER::get_shopdnpwp($w, $p,$value,NULL,$zone_cd, $page);
} else {
	$data = Class_M_OTHER::get_shopdnpwp($w, $p,$value,NULL,NULL, $page);
}

	$smarty->assign('data',  $data);
	$smarty->assign('paraname', $para );
	$smarty->assign('nameval',$value );
	$smarty->assign('beginopen',  $beginopen);
	
	if( isset($forms) )       $smarty->assign('forms', $forms);
	$aoki_area_zones = array();
	$aoki_area_zones[""] = "すべて";
	foreach ($aoki_area_zone as $k => $v) {
		$aoki_area_zones[$k] = $v;
	}
	$smarty->assign('sorts', $aoki_area_zones );
	
	if( isset($zoneuser) )    $smarty->assign('zoneuser', $zoneuser);
	if( isset($areauser) )    $smarty->assign('areauser', $areauser);
	if( isset( $err_mes ) )   $smarty->assign('err', $err_mes);
	

	if ( $forms["sort"]=='2' ) {
		$authtg2 = "block";
	}
	
	if ( $forms["sort"]=='3' ) {
		$authtg2 = "block";
	}

	$smarty->assign('authtg2', $authtg2 );
	$smarty->assign('authtg3', $authtg3 );
	
	
	if( isset($page) )  $smarty->assign('page', $page);
	if ($page['cnt']>0) {
		$smarty->assign( 'pageing', $smarty->fetch('page_search.html') );
	} else {
		$smarty->assign( 'pageing', "情報は見つかりませんでした" );
	}
	
	$smarty->display('msearch_muti_dnpwp_shop.html');
	
	
?>
